扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:mikko 来源:ibm 2007年11月21日
关键字:
HttpConnection con = null; InputStream is = null; String xml = new String(); OutputStream out = null; try { con = (HttpConnection)Connector.open(this.url); con.setRequestMethod(HttpConnection.GET); con.setRequestProperty( "Connection", "close" ); // The call to openInputStream() opens the connection is = con.openInputStream(); // Read the XML file ByteArrayOutputStream bas = new ByteArrayOutputStream(); int ch; while ((ch = is.read()) != -1) { bas.write(ch); } // The xml = bas.toString(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (null!=out) out.close(); if (null!= is) is.close(); con.close(); } catch (Exception ex) { ex.printStackTrace(); } } |
濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�